﻿Public Class viewproducts1
    Dim item As ListViewItem
    Sub listdata()
        If Not rs.EOF Then
            ListView1.Items.Clear()
            rs.MoveFirst()
            Do While Not rs.EOF
                item = ListView1.Items.Add(rs.Fields("productcode").Value)
                item.SubItems.Add(rs.Fields("description").Value)
                item.SubItems.Add("Php " + FormatNumber(rs.Fields("unitprice").Value, 2, True, True, True))

                rs.MoveNext()

            Loop
        Else
            ListView1.Items.Clear()

        End If
        rs.Close()
        rs = Nothing

    End Sub
    Private Sub viewproducts1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Module1.connect()
        rs = New ADODB.Recordset
        rs.Open("select * from products", cn, 3, 2)
        Me.listdata()
       

        RadioButton1.Checked = True
    End Sub



    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        receiptTransaction.Button3.Enabled = True
        receiptTransaction.Button4.Enabled = False
        receiptTransaction.TextBox5.Enabled = True
        receiptTransaction.TextBox5.Text = "1"
        receiptTransaction.TextBox6.Text = ListView1.FocusedItem.Text


    End Sub

   

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        receiptTransaction.TextBox6.Text = ""
        receiptTransaction.TextBox5.Text = "1"
        receiptTransaction.Button3.Enabled = False
        receiptTransaction.Button11.Enabled = True
        Me.Close()
    End Sub

 

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
       
    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

        If RadioButton1.Checked Then
            rs = New ADODB.Recordset
            rs.Open("SELECT * from products where productcode  like '%" & TextBox2.Text & "%'", cn, 3, 2)
            Me.listdata()
        Else
            If RadioButton2.Checked Then
                rs = New ADODB.Recordset
                rs.Open("SELECT * from products where description  like '%" & TextBox2.Text & "%'", cn, 3, 2)
                Me.listdata()
            End If
        End If
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        TextBox2.Text = ""
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        TextBox2.Text = ""
    End Sub

    Private Sub viewproducts1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

    End Sub
End Class